package com.wpc.service;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.wpc.context.Content;
import com.wpc.util.HttpUtil;

@Component
public class FlushKeyTaskService {


	/**
	 * 心跳更新。启动时执行一次，之后每隔30秒执行一次
	 */
	@Scheduled(fixedRate = 1000 * 30)
	public void print() {
		Content.lock=1;
	}

	public static String getKey() {
		return Content.WX_KEY;
	}

	public void flushKey(int uid,String md5key, Long gzhid,String wxkeyurl) {
		synchronized (FlushKeyTaskService.class) {
			if(Content.lock==1){
				HttpUtil.httpGetWxkey(uid, md5key, gzhid, wxkeyurl);
				Content.lock=0;
			}
		}
	}

}
